package com.qcrud.core.parsing;

import com.qcrud.exception.QcrudException;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.lang.reflect.Field;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ColumnInfo {
    /**
     * 字段名
     */
    private String name;
    /**
     * 属性名
     */
    private String property;
    /**
     * 是否类型转换
     */
    private boolean convert;
    /**
     * Java Field
     */
    private Field field;

    public Object fieldGet(Object obj) {
        try {
            field.setAccessible(true);
            return field.get(obj);
        } catch (IllegalAccessException e) {
            throw new QcrudException("bind args error", e);
        }
    }
}
